package onjava.advance.ch02.sec02;

public class OceanReading implements Cloneable {
    private DepthReading depth;
    private TemperatureReading temperature;

    public OceanReading(DepthReading depth, TemperatureReading temperature) {
        this.depth = depth;
        this.temperature = temperature;
    }

    @Override
    protected OceanReading clone() {
        OceanReading or = null;
        try {
            or = (OceanReading) super.clone();
        } catch (CloneNotSupportedException e) {
            throw new RuntimeException(e);
        }
        or.depth = or.depth.clone();
        or.temperature = or.temperature.clone();
        return or;
    }

    public TemperatureReading getTemperatureReading() {
        return temperature;
    }

    public void setTemperatureReading(TemperatureReading temperatureReading) {
        this.temperature = temperatureReading;
    }

    public DepthReading getDepth() {
        return depth;
    }

    public void setDepth(DepthReading depth) {
        this.depth = depth;
    }

    @Override
    public String toString() {
        return "OceanReading{" +
                "depth=" + depth +
                ", temperature=" + temperature +
                '}';
    }
}
